package teacher.action;

import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.struts2.ServletActionContext;

import teacher.bean.Patent;
import teacher.bean.Teacher;
import teacher.page.Page;
import teacher.page.PageUtil;
import teacher.service.patent;
import teacher.service.treatise;

import com.opensymphony.xwork2.ActionSupport;

public class listPat extends ActionSupport{
	
	private List<Patent> patents;
	private int currentPage;
	String suc;

	public String getSuc() {
		return suc;
	}

	public void setSuc(String suc) {
		this.suc = suc;
	}

	public int getCurrentPage() {
		return currentPage;
	}

	public void setCurrentPage(int currentPage) {
		this.currentPage = currentPage;
	}

	public List<Patent> getPatents() {
		return patents;
	}

	public void setPatents(List<Patent> patents) {
		this.patents = patents;
	}

	public String execute()
	{
		HttpServletRequest request=ServletActionContext.getRequest();
		Teacher tea=(Teacher)request.getSession().getAttribute("teacher");
		
		// 获得记录数
		int totalCount = new patent().getCountPatentTea(tea);
		// 设置分页信息
		Page page = PageUtil.createPage(10, totalCount, currentPage);
		//取得该频道下的记录
		patents=new patent().selectPatentByTeacherPage(tea, page);
		
		request.setAttribute("patents",patents);
		request.setAttribute("page",page);
		return SUCCESS;
	}

}

